# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.shortcuts import render

from django.http import HttpResponse,HttpResponseRedirect

from django.urls import reverse
# Create your views here.

#http://127.0.0.1:8000/add/4/5/
#以add/4/5/方式传递a,b参数
def add2(request, a, b):
    c = int(a) + int(b)
    return HttpResponse(str(c))

def index(request):
    return render(request, 'home.html')
#跳转函数，让以前的 /add/3/4/自动跳转到现在新的网址/new_add/4/5/
def old_add2_redirect(request, a, b):
    return HttpResponseRedirect(
        reverse('add2', args=(a, b))#reverse('add2', args=(4,5)),输出结果u'/add/4/5/'
    )
